package com.neusoft.elmboot.exception.exceptions;

import com.neusoft.elmboot.util.response.CodeEnum;
import com.neusoft.elmboot.util.response.ResultBody;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public class BaseException extends RuntimeException{
    protected CodeEnum code;
    protected String msg;

    public BaseException() {
        this.code = CodeEnum.FAILED;
        this.msg = "";
    }

    public ResultBody getResult(){
        if (this.msg == null) {
            return new ResultBody(CodeEnum.FAILED);
        } else {
            return new ResultBody(CodeEnum.FAILED.getResultCode(), msg, null);
        }
    }
}
